<%@ page language="java" contentType="text/html; charset=utf-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>用户权限管理</title>
<link rel="stylesheet" type="text/css"
	href='${pageContext.request.contextPath}/css/styles.css'>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/jquery-1.7.1.js"></script>
<script type="text/javascript">
	$(function() {
		$('tbody > tr:even').css('background-color', 'rgb(240,240,240)');
		//alert($('#dataBody tr>td:last').text());//获取每一行的最后一个单元格
		$("a").each(function() {
			if ($(this).text() == "清除授权") {
				$(this).unbind("click");
				$(this).bind("click", function() {
					//获取到其父元素的第二个子元素，也就是userId的值
					var $vId = $(this).parent().parent().children(':eq(1)').text();
					if (confirm("确认清除所有授权？")) {
						$.post("UserAuthorizedAction_clearAuthorize.action", {
							userId : $vId
						}, function(data) {
							if(data == $vId)
								alert("用户授权已清除");
						});
						return true;
					} else
						return false;
				});
			}
		});
	});
</script>
</head>
<body><!--  
	<s:include value="/WEB-INF/jsp/head/header.jsp" />-->
	<table>
		<tr>
			<td colspan="10" style="height: 5px"></td>
		</tr>
		<tr>
			<td colspan="10" style="height: 5px"></td>
		</tr>
	</table>
	<s:if test="allUsers.isEmpty() == true">目前没有任何用户!</s:if>
	<s:else>
		<table>
			<thead>
				<tr>
					<td colspan="10" style="height: 5px"></td>
				</tr>
				<tr>
					<td colspan="10" class="tdHeader">授权管理:</td>
				</tr>
				<tr>
					<td colspan="10" style="height: 5px"></td>
				</tr>
				<tr>
					<td class="tdListHeader">序号</td>
					<td class="tdListHeader">ID</td>
					<td class="tdListHeader">email</td>
					<td class="tdListHeader">昵称</td>
					<td class="tdListHeader">修改授权</td>
					<td class="tdListHeader">清除授权</td>
				</tr>
			</thead>
			<tbody id="dataBody">
				<s:iterator value="allUsers" status="st">
					<s:set var="userId" value="id" />
					<tr>
						<td><s:property value="#st.count" /></td>
						<td id="userId"><s:property value="id" /></td>
						<td style="text-align: left;"><s:property value="email" /></td>
						<td style="color: gray;text-align: left;"><s:property
								value="nickName" /></td>
						<td><s:a
								action="UserAuthorizedAction_editAuthorize?userId=%{#userId}"
								cssClass="aList">修改授权</s:a></td>
						<td><a id="UserAuthorizedAction_clearAuthorized"
								class="aList" href="#">清除授权</a></td>
					</tr>
				</s:iterator>
			</tbody>
		</table>
	</s:else>
</body>
</html>